1
|
|
|
/** global: VRS */
|
2
|
|
|
if(VRS && VRS.globalDispatch && VRS.serverConfig) {
|
3
|
|
|
VRS.globalDispatch.hook(VRS.globalEvent.bootstrapCreated, function(bootStrap) {
|
|
|
|
|
4
|
|
|
if(VRS.renderPropertyHandlers) {
|
5
|
|
|
VRS.renderPropertyHandlers[VRS.RenderProperty.OperatorFlag] = new VRS.RenderPropertyHandler({
|
6
|
|
|
property: VRS.RenderProperty.OperatorFlag,
|
7
|
|
|
surfaces: VRS.RenderSurface.List + VRS.RenderSurface.DetailHead + VRS.RenderSurface.InfoWindow,
|
8
|
|
|
headingKey: 'ListOperatorFlag',
|
9
|
|
|
labelKey: 'OperatorFlag',
|
10
|
|
|
sortableField: VRS.AircraftListSortableField.OperatorIcao,
|
11
|
|
|
headingAlignment: VRS.Alignment.Centre,
|
12
|
|
|
suppressLabelCallback: function() { return true; },
|
13
|
|
|
fixedWidth: function() { return VRS.globalOptions.aircraftOperatorFlagSize.width.toString() + 'px'; },
|
14
|
|
|
hasChangedCallback: function(aircraft) { return aircraft.operatorIcao.chg || aircraft.icao.chg || aircraft.registration.chg || aircraft.manufacturer.chg; },
|
15
|
|
|
renderCallback: function(aircraft) { return customFormatOperatorIcaoImageHtmlAircraft(aircraft); },
|
16
|
|
|
tooltipChangedCallback: function(aircraft) { return aircraft.operatorIcao.chg || aircraft.operator.chg; },
|
17
|
|
|
tooltipCallback: function(aircraft) { return aircraft.formatOperatorIcaoAndName(); }
|
18
|
|
|
});
|
19
|
|
|
|
20
|
|
|
VRS.renderPropertyHandlers[VRS.RenderProperty.SilhouetteAndOpFlag] = new VRS.RenderPropertyHandler({
|
21
|
|
|
property: VRS.RenderProperty.SilhouetteAndOpFlag,
|
22
|
|
|
surfaces: VRS.RenderSurface.List,
|
23
|
|
|
headingKey: 'ListModelSilhouetteAndOpFlag',
|
24
|
|
|
labelKey: 'SilhouetteAndOpFlag',
|
25
|
|
|
headingAlignment: VRS.Alignment.Centre,
|
26
|
|
|
sortableField: VRS.AircraftListSortableField.OperatorIcao,
|
27
|
|
|
fixedWidth: function() { return Math.max(VRS.globalOptions.aircraftSilhouetteSize.width, VRS.globalOptions.aircraftOperatorFlagSize.width).toString() + 'px'; },
|
28
|
|
|
// Changed the following line to include manufacturer
|
29
|
|
|
hasChangedCallback: function(aircraft) { return aircraft.modelIcao.chg || aircraft.operatorIcao.chg || aircraft.registration.chg || aircraft.manufacturer.chg; },
|
30
|
|
|
// And this line to include a call to the custom HTML
|
31
|
|
|
renderCallback: function(aircraft) { return aircraft.formatModelIcaoImageHtml() + customFormatOperatorIcaoImageHtmlAircraft(aircraft); },
|
32
|
|
|
tooltipChangedCallback: function(aircraft) { return aircraft.model.chg || aircraft.modelIcao.chg || aircraft.countEngines.chg || aircraft.engineType.chg || aircraft.species.chg || aircraft.wakeTurbulenceCat.chg || aircraft.operatorIcao.chg || aircraft.operator.chg; },
|
33
|
|
|
tooltipCallback: function(aircraft) {
|
34
|
|
|
var silhouetteTooltip = aircraft.formatModelIcaoNameAndDetail();
|
35
|
|
|
var opFlagTooltip = aircraft.formatOperatorIcaoAndName();
|
36
|
|
|
return silhouetteTooltip && opFlagTooltip ? silhouetteTooltip + '. ' + opFlagTooltip : silhouetteTooltip ? silhouetteTooltip : opFlagTooltip;
|
37
|
|
|
}
|
38
|
|
|
});
|
39
|
|
|
}
|
40
|
|
|
|
41
|
|
|
if(VRS.reportPropertyHandlers) {
|
42
|
|
|
VRS.reportPropertyHandlers[VRS.ReportAircraftProperty.OperatorFlag] = new VRS.ReportPropertyHandler({
|
43
|
|
|
property: VRS.ReportAircraftProperty.OperatorFlag,
|
44
|
|
|
surfaces: VRS.ReportSurface.List + VRS.ReportSurface.DetailHead,
|
45
|
|
|
headingKey: 'ListOperatorFlag',
|
46
|
|
|
labelKey: 'OperatorFlag',
|
47
|
|
|
headingAlignment: VRS.Alignment.Centre,
|
48
|
|
|
fixedWidth: function() { return VRS.globalOptions.aircraftOperatorFlagSize.width.toString() + 'px'; },
|
49
|
|
|
hasValue: function(/** VRS_JSON_REPORT_AIRCRAFT */ json) { return !!json.opFlag || !!json.icao || !!json.reg || !!json.manufacturer; },
|
50
|
|
|
renderCallback: function(/** VRS_JSON_REPORT_AIRCRAFT */ json) { return customFormatOperatorIcaoImageHtml(json.manufacturer, json.opFlag, json.reg, json.icao); },
|
51
|
|
|
tooltipCallback: function(/** VRS_JSON_REPORT_AIRCRAFT */ json) { return VRS.format.operatorIcaoAndName(json.owner, json.opFlag); }
|
52
|
|
|
});
|
53
|
|
|
}
|
54
|
|
|
});
|
55
|
|
|
}
|
56
|
|
|
|
57
|
|
|
function customFormatOperatorIcaoImageHtmlAircraft(aircraft)
|
58
|
|
|
{
|
59
|
|
|
return customFormatOperatorIcaoImageHtml(aircraft.manufacturer.val, aircraft.operatorIcao.val, aircraft.registration.val, aircraft.icao.val);
|
60
|
|
|
}
|
61
|
|
|
|
62
|
|
|
function customFormatOperatorIcaoImageHtml(manufacturer, operatorIcao, registration, icao)
|
63
|
|
|
{
|
64
|
|
|
var codeToUse = '';
|
65
|
|
|
codeToUse = customPipeSeparatedCode(codeToUse, registration);
|
66
|
|
|
codeToUse = customPipeSeparatedCode(codeToUse, operatorIcao);
|
67
|
|
|
codeToUse = customPipeSeparatedCode(codeToUse, icao);
|
68
|
|
|
codeToUse = customPipeSeparatedCode(codeToUse, manufacturer);
|
69
|
|
|
|
70
|
|
|
var size = VRS.globalOptions.aircraftOperatorFlagSize;
|
71
|
|
|
var result = '<img src="images/File-' + encodeURIComponent(codeToUse);
|
72
|
|
|
if(VRS.browserHelper.isHighDpi()) result += '/HiDpi';
|
|
|
|
|
73
|
|
|
result += '/OpFlag.png"' +
|
74
|
|
|
' width="' + size.width.toString() + 'px"' +
|
75
|
|
|
' height="' + size.height.toString() + 'px"' +
|
76
|
|
|
' />';
|
77
|
|
|
|
78
|
|
|
return result;
|
79
|
|
|
}
|
80
|
|
|
|
81
|
|
|
////////
|
82
|
|
|
|
83
|
|
|
function customPipeSeparatedCode(text, code)
|
84
|
|
|
{
|
85
|
|
|
var result = text;
|
86
|
|
|
if(code && code.length) {
|
87
|
|
|
if(result.length) result += '|';
|
|
|
|
|
88
|
|
|
result += code;
|
89
|
|
|
}
|
90
|
|
|
return result;
|
91
|
|
|
}
|
92
|
|
|
|
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.